//
//  Templet2Cell.m
//  FruitsWholesaler
//
//  Created by sgone-2 on 16/4/8.
//  Copyright © 2016年 sgone. All rights reserved.
//

#import "Templet2Cell.h"
#import "UIImageView+AFNetworking.h"
#import "Common.h"
@implementation Templet2Cell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.backgroundColor = BACKGROUND1;
    self.imageTu = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ViewWidth/3, ViewWidth/3)];
    self.imageTu.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.imageTu];
    
    
    
    self.labelName = [[UILabel alloc]initWithFrame:CGRectMake(2,ViewWidth/3+4, ViewWidth/3, 21)];
    self.labelName.backgroundColor = [UIColor clearColor];
    self.labelName.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.labelName];
    
    
    
    self.labelGuige = [[UILabel alloc]initWithFrame:CGRectMake(2, ViewWidth/3+4+21, ViewWidth/3, 21)];
    self.labelGuige.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:self.labelGuige];
    self.labelGuige.textColor = [UIColor grayColor];
    
    
    self.labelPrice = [[UILabel alloc]initWithFrame:CGRectMake(ViewWidth/3 - 50 , ViewWidth/3+4+21, 45, 21)];
    self.labelPrice.font = [UIFont systemFontOfSize:11];
    [self.contentView addSubview:self.labelPrice];
    self.labelPrice.textColor = BenSe_COLOR;
    self.labelPrice.textAlignment = NSTextAlignmentRight;
    
    
    
    
    self.btnImage = [[UIImageView alloc]initWithFrame:CGRectMake(3, 3, 28, 28)];
    [self.contentView addSubview:self.btnImage];
    
    
//    self.btnGou = [[UIButton alloc]initWithFrame:CGRectMake(3, 3, 28, 28)];
//    self.btnGou.backgroundColor = [UIColor redColor];
//    [self.contentView addSubview:self.btnGou];
    
    
    
    
    
    
    
}


-(void)loadCell:(NSDictionary *)dict2

{

    if ([[dict2 objectForKey:@"image1"] isKindOfClass:[NSNull class]] || [[dict2 objectForKey:@"image1"] length] == 0 ) {
        self.imageTu.image = [UIImage imageNamed:@"backImage"];
    }
    
    NSURL *url = [NSURL URLWithString:[dict2 objectForKey:@"image1"]];
    [self.imageTu setImageWithURL:url placeholderImage:[UIImage imageNamed:@"backImage"]];
    
    self.labelName.text = [NSString stringWithFormat:@"%@",dict2[@"product_name"]];
    
    self.labelGuige.text = [NSString stringWithFormat:@"%@",dict2 [@"product_unit"]];
    
    self.labelPrice.text = [NSString stringWithFormat:@"%@元",dict2[@"unit_price"]];



}

@end
